package cn.chengpengper.seckill.order.application.model.task;

import cn.chengpengper.seckill.common.model.message.TopicMessage;
import cn.chengpengper.seckill.order.application.model.command.SeckillOrderCommand;
import cn.hutool.core.util.StrUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

/**
 * @author chengpeng.hu
 */
@Data
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
public class SeckillOrderTask extends TopicMessage {
    /**
     * 订单任务id
     */
    private String orderTaskId;

    /**
     * 用户id
     */
    private Long userId;

    /**
     * 提交的订单数据
     */
    private SeckillOrderCommand seckillOrderCommand;

    public SeckillOrderTask(String destination, String orderTaskId, Long userId, SeckillOrderCommand seckillOrderCommand) {
        super(destination);
        this.orderTaskId = orderTaskId;
        this.userId = userId;
        this.seckillOrderCommand = seckillOrderCommand;
    }

    public boolean isEmpty(){
        return StrUtil.isEmpty(this.getDestination())
                || StrUtil.isEmpty(orderTaskId)
                || userId == null
                || seckillOrderCommand == null;
    }
}
